package com.bicon.botu.mall.order.api;

import com.bicon.botu.mall.order.dto.GoodsEvaluationParamsDto;
import com.bicon.botu.core.base.common.controller.BaseController;
import com.bicon.botu.core.base.common.entity.BaseResult;
import com.bicon.botu.core.base.common.utils.JsonUtil;
import com.bicon.botu.mall.order.service.IEvaluationService;
import com.google.gson.reflect.TypeToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 评价APP端接口
 *
 * @author 王开亮
 * @date 2018/3/16 17:29
 */
@RestController
@RequestMapping("/V2.0.0/api/evaluation")
public class EvaluationApiV2  extends BaseController{

    @Autowired
    private IEvaluationService evaluationService;

    @RequestMapping(value = "/add" ,method = RequestMethod.POST)
    public BaseResult addEvaluation(@RequestParam("orderId")String orderId,@RequestParam("descFit") int descFit,
                                    @RequestParam("logisticsService") int logisticsService,
                                    @RequestParam("customerService") int customerService,
                                    @RequestParam("anonymous") boolean anonymous,
                                    @RequestParam("goodsEvaluations") String goodsEvaluations){
        String userId = this.getUserId();
        List<GoodsEvaluationParamsDto> goodsEvaluationList = JsonUtil.fromJson(goodsEvaluations,new TypeToken<List<GoodsEvaluationParamsDto>>(){}.getType());
        return this.evaluationService.addEvaluation(userId,orderId,descFit,logisticsService,customerService,anonymous,goodsEvaluationList)?sendResult200():sendResult500();
    }

    @RequestMapping(value = "/list" ,method = RequestMethod.GET)
    public BaseResult getEvaluations(){
        return this.sendResult200();
    }


    @RequestMapping(value = "/list/user" ,method = RequestMethod.GET)
    public BaseResult getEvaluationsByUserId(){
        return this.sendResult200();
    }

    @RequestMapping(value = "/detail" ,method = RequestMethod.GET)
    public BaseResult getEvaluation(){
        return this.sendResult200();
    }

    @RequestMapping(value = "/thumbUp" ,method = RequestMethod.POST)
    public BaseResult thumbUp(){
        return this.sendResult200();
    }



}
